package com.operate.api.app.balance.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.github.pagehelper.PageInfo;
import com.operate.api.app.balance.domain.vo.AppBalanceSearchVO;
import com.operate.api.app.balance.domain.vo.AppBalanceVO;
import com.operate.api.app.balance.domain.vo.AppOrderConsumeVO;
import com.operate.api.app.balance.domain.vo.AppOrderRechargeVO;
import com.operate.api.app.balance.service.IAppBalanceService;
import com.operate.api.app.user.domain.vo.AppUserVO;
import com.operate.api.base.ApiIndex;
import com.operate.api.base.IDEntity;
import com.operate.api.base.R;
import com.operate.api.base.RestPage;
import com.operate.api.operate.meal.domain.vo.PackageSearchVO;
import com.operate.api.operate.meal.domain.vo.PackageVO;
import com.operate.api.operate.meal.service.IPackageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api( tags = ApiIndex.AppBalanceController)
@RequestMapping(value = "/api/app/balance")
@RestController
public class AppBalanceController {

    @Autowired
    private IAppBalanceService service;


    @ApiOperation(value = "查询列表[需要登录]")
    @GetMapping(value = "/list")
    @SaCheckLogin
    public R<RestPage<List<AppBalanceVO>>> list(
            @ApiParam(value = "查询参数") @ModelAttribute AppBalanceSearchVO searchVO) {
        List<AppBalanceVO> list = service.getList(searchVO);
        RestPage restPage = new RestPage(new PageInfo(list), list);
        return new R(restPage);
    }


    @ApiOperation(value = "充值详情[需要登录]")
    @GetMapping(value = "/recharge_desc")
    @SaCheckLogin
    public R<AppOrderRechargeVO> recharge_desc(@ApiParam(value = "订单ID") @Valid @ModelAttribute IDEntity id) {
        AppOrderRechargeVO resVO=service.getRechargeDesc(id.getId());
        return new R(resVO);
    }

    @ApiOperation(value = "消费(解锁)详情[需要登录]")
    @GetMapping(value = "/consume_desc")
    @SaCheckLogin
    public R<AppOrderConsumeVO> consume_desc(@ApiParam(value = "订单ID") @Valid @ModelAttribute IDEntity id) {
        AppOrderConsumeVO resVO=service.getConsumeDesc(id.getId());
        return new R(resVO);
    }



}